<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>用印统计</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../../layuiadmin/layui/css/layui.css" media="all">
    <script type="text/javascript" src="../../layuiadmin/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="../../layuiadmin/layui/xadmin.js"></script>
    <script type="text/javascript" src="../../layuiadmin/js/system/jquery.min.js"></script>
    <script src="../../layuiadmin/js/system/jquery.cookie.js"></script>
    <script>
        $(function () {
            var hrName = $("#hrName");
            $.post("http://localhost:8080/user/getByName",
                function (msg) {
                    for (var i = 0; i < msg.length; i++) {
                        var option = $("<option value=" + msg[i].empId + ">" + msg[i].empName + "</option>");
                        hrName.append(option);
                        layui.use('form', function () {
                            var form = layui.form;
                            form.render("select");
                        });
                    }
                })
        })
    </script>
</head>
<body>
<div class="layui-form" id="form">
    <div class="demoTable">
        <div class="layui-form" wid100 id="divData" style="margin-top: 10px">
            <div class="layui-form-item">
                <div class="layui-inline">
                    <div class="layui-input-inline">
                        <select name="modules" lay-verify="required" lay-search="" id="sealType" >
                            <option value="-1">用印类型</option>
                            <option>立案文书</option>
                            <option>律师函</option>
                            <option>收款文件</option>
                        </select>
                    </div>
                    <div class="layui-input-inline">
                        <select name="modules" lay-verify="required" lay-search="" id="state" >
                            <option value="-1">审批状态</option>
                            <option>已审核</option>
                            <option>未审核</option>
                        </select>
                    </div>
                    <div class="layui-input-inline">
                        <select name="modules" lay-verify="required" lay-search="" id="hrName">
                            <option value="-1">领用人</option>
                        </select>
                    </div>
                    <label class="layui-form-label">结案日期</label>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="test-laydate-start">
                    </div>
                    <div class="layui-form-mid">
                        -
                    </div>
                    <div class="layui-input-inline">
                        <input type="text" class="layui-input" id="test-laydate-end">
                    </div>
                </div>
                <button class="layui-btn" data-type="reload" type="button">搜索</button>
            </div>
            <div class="layui-card">
                <div class="layui-card-header"></div>
                <div class="layui-card-body">
                    <table class="layui-hide" id="test-table-simple"></table>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="../../layuiadmin/layui/layui.js"></script>
<script>
    function createrFormat(o){
        return o;
    }
    layui.use('table', function(){
        var table = layui.table;
        table.render({
            elem: '#test-table-simple'
            ,url: 'http://localhost:8080/usingStatistical/listAudit'
            ,cellMinWidth: 100 //全局定义常规单元格的最小宽度，layui 2.2.1 新增
            ,cols: [[
                {field:'auditid', title: '案号'}
                ,{field:'submit_time',  title: '领用日期', sort: true}
                ,{field:'state',  title: '审批状态'}
                ,{field:'emp_name',  title: '领用人'}
                ,{field:'remark',  title: '用印事项'}
            ]]
            ,page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: [  'prev', 'page', 'next', 'skip','count','limit'] //自定义分页布局
                ,curr: 1 //设定初始在第 1 页
                ,limit:5 //一页显示多少条
                ,limits:[5,10,15]//每页条数的选择项
                ,groups: 2 //只显示 2 个连续页码

            }
            ,id:'table'
        });

        var $=layui.$,active={
            reload:function () {
                var hrName=$("#hrName").val();
                var time1=$("#test-laydate-start").val();
                var time2=$("#test-laydate-end").val();
                var state=$("#state").val();
                var sealType=$("#sealType").val();
                //执行重载
                table.reload('table',{
                    where:{
                        empId:hrName,
                        time1:time1,
                        time2:time2,
                        state:state,
                        sealType:sealType
                    }
                },'data');
            }
        }
        $('.demoTable .layui-btn').on('click',function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });
    layui.config({
        base: '../../layuiadmin/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'laydate'], function(){
        var laydate = layui.laydate;
        //开始日期
        var insStart = laydate.render({
            elem: '#test-laydate-start'
            ,max:'nowtime'
            ,done: function(value, date){
                //更新结束日期的最小日期
                insEnd.config.min = lay.extend({}, date, {
                    month: date.month - 1
                });

                //自动弹出结束日期的选择器
                insEnd.config.elem[0].focus();
            }
        });

        //结束日期
        var insEnd = laydate.render({
            elem: '#test-laydate-end'
            ,min: 0
            ,done: function(value, date) {
                if (date.month!=undefined) {
                    //更新开始日期的最大日期
                    insStart.config.max = lay.extend({}, date, {
                        month: date.month - 1
                    });
                }
            }
        });
    });
</script>
</body>
</html>